<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        
        <meta name="author" content="Mr.Wang">
        <link rel="canonical" href="http://www.mapgoo.net/acc/">
        <link rel="shortcut icon" href="../img/favicon.ico">
        <title>远程唤醒 - 智能麦联</title>
        <link href="../css/bootstrap-custom.min.css" rel="stylesheet">
        <link href="../css/font-awesome-4.5.0.css" rel="stylesheet">
        <link href="../css/base.css" rel="stylesheet">
        <link rel="stylesheet" href="../css/highlight.css">
        <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
        <!--[if lt IE 9]>
            <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
            <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
        <![endif]-->
	
	<script src="../js/jquery-1.10.2.min.js"></script>
        <script src="../js/bootstrap-3.0.3.min.js"></script>
        <script src="../js/highlight.pack.js"></script> 
    </head>

    <body>

        <div class="navbar navbar-default navbar-fixed-top" role="navigation">
    <div class="container">

        <!-- Collapsed navigation -->
        <div class="navbar-header">
            <!-- Expander button -->
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="..">智能麦联</a>
        </div>

        <!-- Expanded navigation -->
        <div class="navbar-collapse collapse">
                <!-- Main navigation -->
                <ul class="nav navbar-nav">
                    <li >
                        <a href="..">对接协议</a>
                    </li>
                    <li class="active">
                        <a href="./">远程唤醒</a>
                    </li>
                    <li >
                        <a href="../llgl/">流量管理</a>
                    </li>
                    <li >
                        <a href="../whitelist/">白名单应用</a>
                    </li>
                    <li >
                        <a href="../link/">联系</a>
                    </li>
                </ul>

            <ul class="nav navbar-nav navbar-right">
                <li>
                    <a href="#" data-toggle="modal" data-target="#mkdocs_search_modal">
                        <i class="fa fa-search"></i> Search
                    </a>
                </li>
                    <li >
                        <a rel="next" href="..">
                            <i class="fa fa-arrow-left"></i> Previous
                        </a>
                    </li>
                    <li >
                        <a rel="prev" href="../llgl/">
                            Next <i class="fa fa-arrow-right"></i>
                        </a>
                    </li>
            </ul>
        </div>
    </div>
</div>

        <div class="container">
                <div class="col-md-3"><div class="bs-sidebar hidden-print affix well" role="complementary">
    <ul class="nav bs-sidenav">
        <li class="main active"><a href="#_1">背景</a></li>
        <li class="main "><a href="#_2">名词解释</a></li>
        <li class="main "><a href="#_3">交互时序</a></li>
        <li class="main "><a href="#_4">交互协议约定</a></li>
        <li class="main "><a href="#_5">中心下发指令约定</a></li>
        <li class="main "><a href="#_6">终端上传指令</a></li>
        <li class="main "><a href="#app4g">APP请求4G模块连接信息</a></li>
    </ul>
</div></div>
                <div class="col-md-9" role="main">

<h2 id="_1">背景</h2>
<blockquote>
<p>智能车载方案商希望硬件在休眠状态下，依然能够正常接受云端下发的控制指令，如：远程拍照、录像等。如何在休眠状态下，依然能让设备与云端保持长链接，这需要在硬件端编写相关代码实现。目前的方案有2种：
 + 智能车载硬件内置<code>智能麦联APK</code>，方案商确保车载硬件休眠状态后，该APK不被kill；
 + 智能车载硬件商，自己实现长链接保持与云平台通讯。这种方式将是本文重点介绍的内容；</p>
</blockquote>
<h2 id="_2">名词解释</h2>
<ul>
<li>唤醒服务器：通指云端平台，由<code>智能麦联</code>提供，包括的服务有：设备接入、下行指令等；</li>
<li>应用：指用户使用APP或微信；</li>
</ul>
<h2 id="_3">交互时序</h2>
<p><img alt="mark" src="http://ohi7mg1ce.bkt.clouddn.com/blog/20161227/133112270.png" /></p>
<h2 id="_4">交互协议约定</h2>
<ul>
<li>双方交互协议使用TCP通信，唤醒服务器监听默认端口为2332；</li>
<li>通信过程中的异常及重发机制：对于需要有响应协议包的业务过程，在通信过程中出现异常时，如果不做特殊说明，协议包的发起方需要进行消息包的重发处理；</li>
<li>协议消息头格式</li>
</ul>
<p><img alt="mark" src="http://ohi7mg1ce.bkt.clouddn.com/blog/20161227/133304093.png" /></p>
<h2 id="_5">中心下发指令约定</h2>
<p><a href="http://mapgoo.oschina.io/znml/#_3">参考链接,详见7.6节</a></p>
<h2 id="_6">终端上传指令</h2>
<ul>
<li>在线待命(心路包)</li>
</ul>
<p><img alt="mark" src="http://ohi7mg1ce.bkt.clouddn.com/blog/20161227/133551996.png" /></p>
<h2 id="app4g">APP请求4G模块连接信息</h2>
<p>APP可以通过http url的方式，获取唤醒服务器的IP和Port。其调用方式如下：</p>
<ul>
<li>接口地址：http://api.4s12580.com/znml/api/car_homeinfo</li>
<li>请求方式：GET</li>
<li>请求参数:</li>
</ul>
<table>
<thead>
<tr>
<th>字段</th>
<th>类型</th>
<th>必填</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>imei</td>
<td>string</td>
<td>true</td>
<td>设备imei</td>
</tr>
<tr>
<td>flag</td>
<td>int</td>
<td>1</td>
<td>获取标记</td>
</tr>
</tbody>
</table>
<ul>
<li>请求举例：http://api.4s12580.com/znml/api/car_homeinfo?Imei=123434&amp;flag=1</li>
<li>返回结果：</li>
</ul>
<pre><code>{
    &quot;error&quot;:0,
    &quot;reason&quot;:&quot;OK&quot;,
    &quot;result&quot;:{
     &quot;ip&quot;: &quot;112.112.112.112&quot;,
     &quot;port&quot;: 1233
    }
</code></pre></div>
        </div>

        <footer class="col-md-12">
            <hr>
                <p>Copyright (c) 2016 by MapGoo</p>
            <p>Documentation built with <a href="http://www.mkdocs.org/">MkDocs</a>.</p>
        </footer>
        <script>var base_url = '..';</script>
        <script data-main="../mkdocs/js/search.js" src="../mkdocs/js/require.js"></script>
        <script src="../js/base.js"></script><div class="modal" id="mkdocs_search_modal" tabindex="-1" role="dialog" aria-labelledby="Search Modal" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title" id="exampleModalLabel">Search</h4>
            </div>
            <div class="modal-body">
                <p>
                    From here you can search these documents. Enter
                    your search terms below.
                </p>
                <form role="form">
                    <div class="form-group">
                        <input type="text" class="form-control" placeholder="Search..." id="mkdocs-search-query">
                    </div>
                </form>
                <div id="mkdocs-search-results"></div>
            </div>
            <div class="modal-footer">
            </div>
        </div>
    </div>
</div>

    </body>
</html>
